package com.juyu.miliao.authentication.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import com.juyu.miliao.common.dataSource.MultipleDataSourceParser;

/**
 * @author pengs
 *
 */
@Service
public class CreateUserId {
	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	@Autowired
	private MultipleDataSourceParser multipleDataSourceParser;

	public Long getUserId() {
		long increment = stringRedisTemplate.opsForValue().increment("userId", 1L);
		return (increment + 100000) * 100 + increment % multipleDataSourceParser.getSubDataSourceNames("miliao-user").size();
	}
	
}
